﻿@*@model IEnumerable<DHQGHN.PM2.Models.EnumeratorModel>*@
@{
    ViewBag.Title = "Reset mật khẩu";
    ViewBag.Root = "Reset mật khẩu";
    //Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<script src="@Url.Content("~/assets/global/plugins/jquery-1.11.0.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/assets/global/plugins/bootstrap/css/bootstrap.min.css")" rel="stylesheet" type="text/css" />

<script>
    @functions{
        public string GetAntiForgeryToken()
        {
            string cookieToken, formToken;
            AntiForgery.GetTokens(null, out cookieToken, out formToken);
            return cookieToken + "," + formToken;
        }
    }

</script>


<div class="container">
    <div class="row">
        <div class="col-md-5">
            <h1>Reset mật khẩu</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-md-5">
            <input type="text" class="input-lg form-control" name="text1" id="text1" placeholder="User Name" autocomplete="off">
            <div class="row">
                <div class="col-sm-6" id="UserName" hidden="hidden" style="color:red;">
                    <span id="8char" class="glyphicon glyphicon-remove" style="color:#FF0004;"></span> Chưa nhập tài khoản<br>
                </div>
            </div>

            <input type="text" class="input-lg form-control" name="text2" id="text2" placeholder="Email" autocomplete="off" style="margin-top:5px;">
            <div class="row">
                <div class="col-sm-6" id="Email" hidden="hidden" style="color:red;">
                    <span id="8char" class="glyphicon glyphicon-remove" style="color:#FF0004;"></span> Chưa nhập Email<br>
                </div>
            </div>

            <input type="button" class="btn btn-primary" data-loading-text="Reset Password..." value="Khôi phục mật khẩu" onclick="ResetPassWord()" style="margin-top:5px;float:right">

        </div>
    </div>
</div>

<script>
    var ConditionPass = "";
    var ConditionTrueFales = false;
    function ResetPassWord() {
        $('#Email').hide();
        $('#UserName').hide();

        ConditionPass = "";
        if ($('#text1').val() == "") {
            $('#UserName').show();
            ConditionPass = "1";
        }
        if ($('#text2').val() == "") {
            $('#Email').show();
            ConditionPass = "1";
        }
        if (ConditionPass == "1") {
            return false;
        }
        else {
            $.ajax({
                url: "@Url.Action("ResetPassWord", "Login")",
                type: "POST",
                data: {
                    UserName: $('#text1').val(),
                    Email: $('#text2').val()
                },
                success: function (Respond) {
                    if (Respond == true) {
                        alert("Reset Pass thành công. Yêu cầu vào Email xác nhận mật khẩu");
                    }
                    else {
                        alert("Tài khoản hoặc Email không đúng!");
                        return false;
                    }
                }
            });
        }
    }

</script>
